<template>
	<view class="container">
		<uni-card :is-shadow="true" :title="roominfo.address" v-if="show">
			<view class="xztv-row xztv-row-between">
				<view>
					<text>抵扣劵:</text>
					<text style="font-size: 36rpx;font-weight: 700;color:red">
						￥{{roominfo.welfare_car_balance}}
					</text>
				</view>
				<view>
					<text>每年60小时 5元/小时</text>
				</view>
			</view>
			
		</uni-card>
		
		<block v-for="(item,index) in carList" :key="index">
			<uni-card :is-shadow="true" :title="item.plateNumber" >
				<view>姓名:{{item.empName}}</view>
				<view>手机:{{item.empMoblie}}</view>
				<template v-slot:actions>
					<view class="card-actions" style="position:absolute;right:20rpx;top:15rpx;bottom: 15rpx;">
						
						<view class="card-actions-item" @click="deletePlateNumber(item)">
							<uni-icons type="trash" size="18" color="#999"></uni-icons>
							<text class="card-actions-item-text">删除</text>
						</view>
					</view>
				</template>
			</uni-card>
		</block>
		<view v-if="carList.length==0" style="height: 500rpx;">
			<empty ></empty>
		</view>
		
		
		<view class="add-btn zaozao-flex-center"  @click="addPlateNum" >
			<text>添加车牌</text>
		</view>
		
		<view style="height: 200rpx;margin-top:100rpx;width: 702rpx;margin-left:24rpx;color:black">
			<view style="color: red;">
				温馨提示：
			</view>
			<view style="margin-top:20rpx;font-size:28rpx;">
				1、福利车减免是小区所有业主享有的权益，每年系统会自动发放60小时 (相当于300元抵扣券)用完即止，如果车辆收费需使用现金或扫码支付完成。
			</view>
			<view style="margin-top:20rpx;font-size:28rpx;">
				2、小区收费标准:外来车辆或业主车辆停放南北商铺路面开始计费5元/小时，免费30分钟后开始计费;每日24小时封顶收取30元/天，相当于6小时长，系统计算为准，以此类推。
			</view>
			<view style="margin-top:20rpx;font-size:28rpx;">
				3、抵扣券不兑换、不找零。
			</view>
		</view>
	</view>
</template>

<script>
	import {getList,deletePlateNumber} from "@/api/welfare.js";
	export default {
		data() {
			return {
				show:false,
				roominfo:{
					welfare_car_balance:0
				},
				carList:[]
			}
		},
		onLoad() {
			console.log("yangzl");
			
		},
		onShow(){
			uni.showLoading({
				title: '加载中'
			});
			this.getList()
		},
		methods: {
			getList(){
				getList().then((res)=>{
					uni.hideLoading();
					this.show=true;
					if(res.data.code==0){
						this.carList=res.data.data;
						this.roominfo=res.data.roominfo;
					}
					console.log("res",res);
				})
			},
			deletePlateNumber(item){
				let that=this;
				uni.showModal({
					title:"删除车牌",
					content:"删除后无法恢复，是否确定删除？",
					success: function (res) {
						if (res.confirm) {
							console.log('用户点击确定');
							that.deletePlateNumberAction(item)
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				})
			},
			deletePlateNumberAction(item){
				deletePlateNumber(item).then((res)=>{
					if(res.data.code==0){
						uni.showToast({
							title:res.data.msg,
							duration:2000,
							icon:"success"
						});
						this.getList()
					}else{
						uni.showToast({
							title:res.data.msg,
							duration:2000,
						});
					}
				})
			},
			addPlateNum(){
				this.$navigateCheck(`/pages/car/welfare/add`)
			},
			carModal(){
			    this.$refs.popupRef.open()
			},
			carInput(numList){
			    this.car = numList.join('')
			}
		}
	}
</script>

<style scoped lang="less">
	.xztv-row {
		display: flex;
		flex-direction: row;
	}
	.xztv-row-between {
		justify-content: space-between;
	}
	.container{
	  width:750rpx;
	  
	}
	.add-btn{
		width: 702rpx;
		height: 80rpx;
		background: #40C7B8;
		border-radius: 156rpx;
		opacity: 1;
		margin-left:24rpx;
		color:white;
		
	}
</style>